// Author: LeoDuan
// Date: 2021/4/5 22:11

package models

import (
	"fmt"

	"github.com/astaxie/beego/orm"
)

type User struct {
	Id   int
	Name string
	Sex  int8
}

func init() {
	orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/beego_demo?charset=utf8")
	orm.RegisterModel(new(User))
}

func PrintUserByOrm() {
	o := orm.NewOrm()
	user := User{Id: 3}
	o.Read(&user)
	fmt.Println(user)
}
